<!--
 * @Descripttion: |
 * @version: 1.0
 * @Author: 王娆
 * @Date: 2020-08-23 17:35:04
 * @LastEditors: 王娆
 * @LastEditTime: 2020-08-27 19:59:35
-->
<template>
  <el-container>
    <el-header>
      <img src="../assets/logo1.png" alt />
      <div>
        <span class="avtar"></span>
        <p>{{username}}</p>
      </div>
    </el-header>
    <el-container>
      <div class="aside">
        <el-menu
          default-active="2"
          class="el-menu-vertical-demo"
          background-color="#232A41"
          text-color="#fff"
          active-text-color="#ffd04b"
          unique-opened
        >
          <el-submenu :index="item.id.toString()" v-for="item in newFilterList" :key="item.id">
            <template slot="title">
              <i class="el-icon-location"></i>
              <span>{{item.title}}</span>
            </template>
            <el-menu-item-group>
              <el-menu-item :index="ite.id.toString()" v-for="ite in item.children.filter(i=>i.title)" :key="ite.id" @click="handelNavItem(item.path,ite.path)">{{ite.title}}</el-menu-item>
            </el-menu-item-group>
          </el-submenu>
        </el-menu>
      </div>
      <el-main>
        <router-view />
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import {mapState} from 'vuex'
export default {
  data() {
    return {
      username: '',
      newFilterList: []
    }
  },
  created() {
    const user = sessionStorage.getItem('user_name')
    this.username = user
    let newFilter = this.filterRouter[0].children.slice(1)
    this.newFilterList = newFilter
    console.log(this.newFilterList)
  },
  methods:{
    handelNavItem(path1,path2){
      console.log(path1,path2)
      this.$router.push(`/${this.filterRouter[0].path}/${path1}/${path2}`)
      console.log(this.filterRouter,'this.filterRouter')
    }
  },
  computed:{
    ...mapState('GetAuth',['filterRouter'])
  }
}
</script>

<style lang='scss' scoped>
.el-container {
  width: 100%;
  height: 100%;
}

.el-header {
  box-shadow: 2px 2px 3px #333;
  background-color: #fff;
  color: #333;
  text-align: center;
  line-height: 60px;
  display: flex;
  justify-content: space-between;
  img {
    height: 60px;
  }
  div {
    height: 60px;
    line-height: 60px;
    display: flex;
    .avtar {
      height: 30px;
      width: 30px;
      border-radius: 50%;
      background: #ccc;
      display: inline-block;
      margin-top: 15px;
      margin-right: 10px;
    }
  }
}
.aside {
  background-color: #232A41;
  color: #333;
  text-align: center;
  line-height: 200px;
  border: 0;
}
.el-menu{
  width:200px;
}
.el-main {
  background-color: #e9eef3;
  color: #333;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
</style>
